package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
class ModuleController{

    @RequestMapping("/doHandleRequest/{n1}/{n2}")
    @ResponseBody
    public String doHandleRequest(@PathVariable Integer n1,@PathVariable Integer n2){
//        异常处理一    try{}cathe{}
        Integer result = n1/n2;
        return "result="+result;
    }
//异常处理二   类内处理
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public String doHandle(ArithmeticException e){
        e.printStackTrace();
        return "异常为"+e.getMessage();
    }

}
